package cn.kgc.layui.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * @author: mosin
 * @version: v1.0  2022/9/15
 * 通过监听application域对象的创建 添加全局的虚拟路径
 */
@WebListener
public class AddBasePathListener  implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {

        //获取项目的虚拟路径  存储在应用上下文对象中
        String contextPath = sce.getServletContext().getContextPath();
        sce.getServletContext().setAttribute("bp", contextPath);

    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }
}
